package com.example.mybatisplus.practice.web;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.mybatisplus.practice.model.SysUser;
import com.example.mybatisplus.practice.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mundo
 * @since 2021-01-27
 */
@RestController
@RequestMapping("/sys-user")
public class SysUserController {
    @Autowired
    private ISysUserService iSysUserService;
    @RequestMapping("test")
    public Object test(HttpServletRequest request){
        String name = request.getParameter("name");
        return "Hello " + name;
    }

    @RequestMapping("list")
    public List<SysUser> queryUserList(){
        List<SysUser> list = iSysUserService.list();
        return list;
    }

    @RequestMapping("queryOne")
    public SysUser queryOne(){
        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>();
//        queryWrapper.eq("name","张三");
        queryWrapper.likeRight("name","李");
        return iSysUserService.getOne(queryWrapper);
    }
}
